﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class chatTestss : MonoBehaviour
{

    public HandleChatItem template;

    public RectTransform sprite;
    public ScrollRect scroll;
    public InputField input;
    public Button creator;
    Transform paren;
    private void Awake()
    {
        creator.onClick.AddListener(() =>
        {
            Creator(input.text);
        });
        paren = template.transform.parent;
        for (int i = 0; i < 10; i++)
        {
            HandleChatItem item = Instantiate(template);
            item.transform.SetParent(paren);
            item.transform.localScale = Vector3.one;//[1#angry]
            item.gameObject.SetActive(true);
            item.Text = "那么我建议你可以先在网上搜一下[0#emoji_9]每一块知识[-1#网上搜一下每]的快速入门[1#angry]那么我建议你可以先在[0#emoji_1]的快速可以先在[0#emoji_4]的快速可以先在[0#emoji_3]的快速入";
        }
        scroll.onValueChanged.AddListener((Pose) =>
        {
            sprite.anchoredPosition = scroll.content.anchoredPosition;
        });
    }
    bool begain = false;
    public void Creator(string ssss)
    {

        HandleChatItem item = Instantiate(template);
        item.transform.SetParent(paren);
        item.transform.localScale = Vector3.one;
        item.gameObject.SetActive(true);

        item.Text = ssss;

    }
    //private void Update()
    //{
    //    // Debug.Log(scroll.verticalNormalizedPosition);
    //    if(begain)
    //      scroll.verticalNormalizedPosition = Mathf.Lerp(scroll.verticalNormalizedPosition, -0.03f, Time.deltaTime*10);

    //    if (scroll.verticalNormalizedPosition <= 0)
    //    {
    //        begain = false;
    //        Debug.Log("qwwe");
    //    }

    //}
}
